//
//  tomorrowViewController.m
//  weather
//
//  Created by Mfk on 12-11-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "tomorrowViewController.h"

@interface tomorrowViewController ()

@end

@implementation tomorrowViewController
@synthesize cityName;
@synthesize tomoWeather;
@synthesize tomoTemp;
@synthesize tomoWind;
@synthesize tomoDetail;
@synthesize delegate;
@synthesize cityDict2;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
           }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    //标题
    self.navigationItem.title=@"明天";
    //获取天气资料
    self.cityDict2=[self.delegate returnWeatherInfoTo:self];
    
    NSString *weather=[self.cityDict2 objectForKey:@"weather2"];
    //根据天气设置背景
    
    [self.delegate weatherNeedDisplay:weather toController:self];
    //将代理重新设为self
    self.delegate=self;
    //调用代理方法显示
    [self.delegate weatherInfoDisplay];
     //NSLog(@"%@",self.cityDict2);
	    
    
}//显示天气
-(void)weatherInfoDisplay{
    
    self.tomoWeather.text=[self.cityDict2 objectForKey:@"weather2"];
    self.tomoTemp.text=[self.cityDict2 objectForKey:@"temp2"];
    self.tomoWind.text=[self.cityDict2 objectForKey:@"wind2"];
    self.tomoDetail.text=[self.cityDict2 objectForKey:@"index48_d"];
    
    
    
}
- (void)viewDidUnload
{
    [self setTomoWeather:nil];
    [self setTomoTemp:nil];
    [self setTomoWind:nil];
    [self setTomoDetail:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)backToToday:(id)sender {
    //[self.presentingViewController dismissModalViewControllerAnimated:YES];
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString: @"toTheDayAfterTomorrow"])
    {
        thedayaftertomorrowViewController *controller=segue.destinationViewController;
        if([controller respondsToSelector:@selector(setDelegate:)])
        {
            [controller setValue:self forKey:@"delegate"];
        }
        
    }
}

//
-(NSDictionary *)returnWeatherInfoTo:(BaseViewController *)controller{
    return self.cityDict2;
}
@end
